<template>
  <div class="baseFile">
    <!-- 按钮 -->
    <div class="btns">
      <el-form size="small" inline style="text-align:center">
          <el-form-item label="请输入名称">
          <el-input v-model="param.fileName"></el-input>
          </el-form-item>
          <el-form-item>
              <el-button size="small" type="primary" icon="el-icon-search" @click="loadBaseFiles">搜索</el-button>
         </el-form-item>
      </el-form>
     <el-button size="small" type="primary" icon="el-icon-circle-plus-outline" @click="toAddHandler" >编辑</el-button>
    </div>
  
    <!-- /按钮 -->
    <!-- {{baseFiles}} -->
    <!-- 表格 -->
    <el-table size="small" :data="baseFiles">
      <el-table-column type="index" :index="1" label="序号" width="60"></el-table-column>
      <el-table-column label="名称" prop="fileName" align="center"></el-table-column>
      <el-table-column label="所属组名" prop="groupName" align="center"></el-table-column>
      <el-table-column label="上传时间" prop="uploadTime" align="center"></el-table-column>
      <el-table-column label="属性" prop="extName" align="center"></el-table-column>
      <el-table-column label="文件大小" prop="fileSize" align="center"></el-table-column>
      <el-table-column label="文件类型" prop="fileType" align="center"></el-table-column>
       <el-table-column label="操作" width="180px" align="center">
        <template slot-scope="scope">
          <el-button type="text" size="mini" round icon="el-icon-delete" @click="deleteHandler(scope.row)"
            >删除</el-button>
          <el-button type="text" size="mini" round icon="el-icon-edit" @click="editHandler(scope.row)"
            >修改</el-button>
        </template>
       </el-table-column>
    </el-table>
    <!-- /表格 -->
  </div>
</template>
<script>
import {get,post,del} from '@/utils/request'
export default {
  // 页面数据
  data(){
    return {
     param:{},
      baseFiles:[]
    }
  },
  // 所有的方法
 methods:{
          // 跳转 
    editHandler(row){
        // 跳转到修改
        // this
        // 携带当前行
        this.$router.push({
          path:"/baseFile/baseFileCreate",
          query:row

        })
    },
   deleteHandler(row) {
      this.$confirm("此操作将永久删除该文件, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        let url = "http://localhost:8888/baseFile/deleteById";
        del(url, {id:row.id }).then((resp) => {
          this.$message({ type: "success", message: resp.message });
          this.loadBaseFiles();
        });
      });
    },
     toAddHandler(){
         this.$router.push("/baseFile/baseFileCreate");
        this.visible = true
     },
    loadBaseFiles(){
      let url = "http://localhost:8888/baseFile/query"
      get(url,this.param).then(resp => {
        this.baseFiles = resp.data;
         })
       }
    },
  // 页面加载的时候会执行的方法
  created(){
    this.loadBaseFiles();
  },
 }

</script>
<style scoped>
.btns{
    margin-bottom: .5em;
}
</style>
